import sys
from loguru import logger as loguru_logger
from app.settings import settings


class Loggin:

    def __init__(self):
        debug = settings.DEBUG
        if debug:
            self.level = "DEBUG"
        else:
            self.level = "INFO"

    def setup_logger(self):
        loguru_logger.remove()
        loguru_logger.add(sink=sys.stdout, level=self.level)
        loguru_logger.add("myapp.log", level=self.level, rotation="100 MB")

        return loguru_logger


loggin = Loggin()
logger = loggin.setup_logger()
